package com.bluegalaxy.sitescore.service.impl;

import com.bluegalaxy.sitescore.entity.TbSiteInfo;
import com.bluegalaxy.sitescore.entity.TbSiteSource;
import com.bluegalaxy.sitescore.entity.TbSoilExposure;
import com.bluegalaxy.sitescore.mapper.TbSiteInfoMapper;
import com.bluegalaxy.sitescore.mapper.TbSiteSourceMapper;
import com.bluegalaxy.sitescore.mapper.TbSoilExposureMapper;
import com.bluegalaxy.sitescore.service.ITbSoilExposureService;
import com.bluegalaxy.sitescore.service.support.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by LZRuil on 2017/12/22.
 */
@Service
public class ITbSoilExposureServiceImpl extends BaseServiceImpl<TbSoilExposureMapper, TbSoilExposure> implements ITbSoilExposureService {

    @Autowired
    private TbSoilExposureMapper tbSoilExposureMapper;

    @Autowired
    private TbSiteSourceMapper tbSiteSourceMapper;

    @Autowired
    private TbSiteInfoMapper tbSiteInfoMapper;

    @Override
    public TbSoilExposure selectById(Integer id) {
        System.out.println("-----------------------"+id);
//        return tbSoilExposureMapper.selectBySiteId(id).get(0);
        /*TbSiteInfo tbSiteInfo = new TbSiteInfo();
        tbSiteInfo.setId(id);
        tbSiteInfo = tbSiteInfoMapper.selectOne(tbSiteInfo);*/
      // System.out.println(tbSiteInfo.getId());
        TbSoilExposure tbSoilExposure = new TbSoilExposure();
        tbSoilExposure.setSource_id(id);
      /* tbSoilExposure = baseMapper.selectOne(tbSoilExposure);*/
      tbSoilExposure = tbSoilExposureMapper.selectOne(tbSoilExposure);
//        System.out.println("---------------------"+tbSoilExposureMapper.selectOne(tbSoilExposure));
        return  tbSoilExposure;
    }

    @Override
    public boolean insertTbSoilExposure(TbSoilExposure tbSoilExposure) {
        tbSoilExposureMapper.insert(tbSoilExposure);
        return true;
    }

    @Override
    public boolean updateTbSoilExposure(TbSoilExposure tbSoilExposure) {
        tbSoilExposureMapper.updateById(tbSoilExposure);
        return true;
    }

    @Override
    public int getCountById(int id) {
        TbSoilExposure tbSoilExposure = new TbSoilExposure();
        tbSoilExposure.setSource_id(id);
        int count = tbSoilExposureMapper.selectCount(tbSoilExposure);
        return count;
    }

}
